package cn.org.eshow.model;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 平台订单收入统计表
 */
@Entity
@Table(name = "product_order_summary")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ProductOrderSummary extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;//平台订单收入统计ID

    @Column(name = "add_time", nullable = false, length = 0)
    private Date addTime = new Date();//添加时间

    @Column
    private String type;//类型（daily日汇总，monthly月汇总）

    @Column
    private Integer year;//年

    @Column
    private Integer month;//月

    @Column
    private Integer week;//周

    @Column
    private Integer day;//日

    @Column(name = "receive_size")
    private Integer receiveSize;//收入流水数

    @Column(name = "online_outlay_size")
    private Integer onlineOutlaySize;//线上退款流水数

    @Column(name = "offline_outlay_size")
    private Integer offlineOutlaySize;//线下退款流水数

    @Column
    private Double receive;//收入金额

    @Column(name = "online_outlay")
    private Double onlineOutlay;//线上退款金额

    @Column(name = "offline_outlay")
    private Double offlineOutlay;//线上退款金额

    public ProductOrderSummary() {
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Integer getMonth() {
        return month;
    }

    public void setMonth(Integer month) {
        this.month = month;
    }

    public Integer getWeek() {
        return week;
    }

    public void setWeek(Integer week) {
        this.week = week;
    }

    public Integer getDay() {
        return day;
    }

    public void setDay(Integer day) {
        this.day = day;
    }

    public Integer getOnlineOutlaySize() {
        return onlineOutlaySize;
    }

    public void setOnlineOutlaySize(Integer onlineOutlaySize) {
        this.onlineOutlaySize = onlineOutlaySize;
    }

    public Integer getOfflineOutlaySize() {
        return offlineOutlaySize;
    }

    public void setOfflineOutlaySize(Integer offlineOutlaySize) {
        this.offlineOutlaySize = offlineOutlaySize;
    }

    public Integer getReceiveSize() {
        return receiveSize;
    }

    public void setReceiveSize(Integer receiveSize) {
        this.receiveSize = receiveSize;
    }

    public Double getReceive() {
        return receive;
    }

    public void setReceive(Double receive) {
        this.receive = receive;
    }

    public Double getOnlineOutlay() {
        return onlineOutlay;
    }

    public void setOnlineOutlay(Double onlineOutlay) {
        this.onlineOutlay = onlineOutlay;
    }

    public Double getOfflineOutlay() {
        return offlineOutlay;
    }

    public void setOfflineOutlay(Double offlineOutlay) {
        this.offlineOutlay = offlineOutlay;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", this.id)
                .append("addTime", this.addTime)
                .append("type", this.type)
                .append("year", this.year)
                .append("month", this.month)
                .append("week", this.week)
                .append("day", this.day)
                .append("receive", this.receive)
                .append("onlineOutlay", this.onlineOutlay)
                .append("offlineOutlay", this.offlineOutlay)
                .toString();
    }


    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        ProductOrderSummary pojo = (ProductOrderSummary) o;

        if (id != null ? !id.equals(pojo.id) : pojo.id != null)
            return false;
        if (addTime != null ? !addTime.equals(pojo.addTime) : pojo.addTime != null)
            return false;
        if (type != null ? !type.equals(pojo.type) : pojo.type != null)
            return false;
        if (year != null ? !year.equals(pojo.year) : pojo.year != null)
            return false;
        if (month != null ? !month.equals(pojo.month) : pojo.month != null)
            return false;
        if (week != null ? !week.equals(pojo.week) : pojo.week != null)
            return false;
        if (day != null ? !day.equals(pojo.day) : pojo.day != null)
            return false;
        if (receive != null ? !receive.equals(pojo.receive) : pojo.receive != null)
            return false;
        if (onlineOutlay != null ? !onlineOutlay.equals(pojo.onlineOutlay) : pojo.onlineOutlay != null)
            return false;
        if (offlineOutlay != null ? !offlineOutlay.equals(pojo.offlineOutlay) : pojo.offlineOutlay != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result;
        result = (id != null ? id.hashCode() : 0);
        result = 31 * result + (addTime != null ? addTime.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (year != null ? year.hashCode() : 0);
        result = 31 * result + (month != null ? month.hashCode() : 0);
        result = 31 * result + (week != null ? week.hashCode() : 0);
        result = 31 * result + (day != null ? day.hashCode() : 0);
        result = 31 * result + (receive != null ? receive.hashCode() : 0);
        result = 31 * result + (onlineOutlay != null ? onlineOutlay.hashCode() : 0);
        result = 31 * result + (offlineOutlay != null ? offlineOutlay.hashCode() : 0);
        return result;
    }
}
